package cn.com.dhcc.ddi.node.service;

import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.dhcc.app.core.exception.DaoException;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.service.BaseService;
import cn.com.dhcc.app.core.service.Log;
import cn.com.dhcc.app.core.service.Log.LOGTYPE;
import cn.com.dhcc.ddi.node.dao.OrgInfoDao;
import cn.com.dhcc.ddi.node.vo.OrgInfo;
/**
 * 
    * @ClassName: OrgInfoService
    * @Description: 地区编码Service
    * @author 18315
    * @date 2017-3-10
    *
 */
@Service
public class OrgInfoService extends BaseService {
	
	private static Logger logger = Log.getLogger(LOGTYPE.DDI);
	private static final Object sendLock = new Object();
	@Autowired
	private OrgInfoDao orgInfoDao;
	
	/**
	 * 根据节点编码查询区域列表
	 * @param code 
	 * @return List<{@link OrgInfo}>
	 * @throws ServiceException 
	 */
	public List<OrgInfo> getOrgInfoByCode(String code) throws ServiceException {
		try {
			return orgInfoDao.getOrgInfoList(code);
		} catch (DaoException e) {
			throw new ServiceException("获取节点区域列表失败", e);
		}
	}
	
	/**
	 * 根据节点编码获取区域实例
	 * @param code
	 * @return
	 * @throws ServiceException
	 */
	public OrgInfo getOrgInfo(String orgcode) throws ServiceException{
		try {
			return orgInfoDao.getOrgInfo(orgcode);
		} catch (DaoException e) {
			throw new ServiceException("获取节点区域列表失败", e);
		}
	}
	
	
	
	
	/**
	 * 行政区
	 * 
	 * @param orgCode 行政区代码
	 * @return
	 * @throws ServiceException
	 */
	public List<OrgInfo> getOrgCode()
			throws ServiceException {
		try {
			return orgInfoDao.getOrgCode();
		} catch (DaoException e) {
			throw new ServiceException("获取行政区失败", e);
		}
	}
	

	/**
	 * 获取行政区
	 * @param nodeCode
	 * @return
	 * @throws ServiceException
	 */
	public OrgInfo get(String nodeCode) throws ServiceException {
		try {
			return orgInfoDao.get(nodeCode);
		} catch (DaoException e) {
			throw new ServiceException("获取行政区失败", e);
		}
	}

	
	
}
